#include "CLogField.h"

CLogField::CLogField()
	: m_name(""), m_value("") {
}	

CLogField::CLogField(const std::string& name, const CLogValue& value)
	: m_name(name), m_value(value) {
}

const std::string& CLogField::GetName() const {
	return m_name;
}

const CLogValue& CLogField::GetValue() const {
	return m_value;
}

EFieldType CLogField::GetType() const {
	if (boost::get<uint64_t>(&m_value)) {
		return EFieldType::EFieldTypeInt;
	} else if (boost::get<double>(&m_value)) {
		return EFieldType::EFieldTypeFloat;
	} else if (boost::get<std::string>(&m_value)) {
		return EFieldType::EFieldTypeString;
	}
	return EFieldType::EFieldTypeUnknown;
}

int CLogField::getSize() const
{
	if (m_value.type() == typeid(std::string)) {
		return static_cast<int>(boost::get<std::string>(m_value).size());
	}

	return sizeof(uint64_t);
}
